################################################################################
#
# nxp s32 s32g pfeng features
#
################################################################################
LLCE_INSTALL_IMAGES = YES

LLCE_FIRMWARE_VERSION = $(call qstrip,$(BR2_PACKAGE_S32_LLCE_FIRMWARE_VERSION))
LLCE_FIRMWARE_SOC_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32_SOC_PLATFORM))
ifeq ($(LLCE_FIRMWARE_SOC_PLATFORM),"S32G")
LLCE_FIRMWARE_MAIN_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32G_MAIN_PLATFORM))
else
LLCE_FIRMWARE_MAIN_PLATFORM = $(call qstrip,$(BR2_PACKAGE_NXP_S32R_MAIN_PLATFORM))
endif
LLCE_FIRMWARE_DIR = package/nxp/s32/llce/firmware/$(LLCE_FIRMWARE_VERSION)/$(LLCE_FIRMWARE_MAIN_PLATFORM)
LLCE_FIRMWARE_INSTALL_TARGET_DIR = $(TARGET_DIR)/lib/firmware
LLCE_FIRMWARE_INSTALL_IMAGE_DIR = $(BINARIES_DIR)/firmware

define LLCE_LINUX_CONFIG_FIXUPS
	$(if $(BR2_PACKAGE_LLCE_BASE),
		$(call KCONFIG_SET_OPT,CONFIG_LLCE_CORE,m)
		$(call KCONFIG_SET_OPT,CONFIG_NXP_LLCE_MBOX,m))
	$(if $(BR2_PACKAGE_LLCE_CAN),
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE,y)
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE_CONTROLLER,m))
	$(if $(BR2_PACKAGE_LLCE_CAN_LOGGER),
		$(call KCONFIG_SET_OPT,CONFIG_CAN_LLCE_LOGGER,m))
endef

define LLCE_INSTALL_TARGET_CMDS
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/dte.bin $(LLCE_FIRMWARE_INSTALL_TARGET_DIR)/dte.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/frpe.bin $(LLCE_FIRMWARE_INSTALL_TARGET_DIR)/frpe.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/ppe_rx.bin $(LLCE_FIRMWARE_INSTALL_TARGET_DIR)/ppe_rx.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/ppe_tx.bin $(LLCE_FIRMWARE_INSTALL_TARGET_DIR)/ppe_tx.bin
endef

define LLCE_INSTALL_IMAGES_CMDS
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/dte.bin $(LLCE_FIRMWARE_INSTALL_IMAGE_DIR)/dte.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/frpe.bin $(LLCE_FIRMWARE_INSTALL_IMAGE_DIR)/frpe.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/ppe_rx.bin $(LLCE_FIRMWARE_INSTALL_IMAGE_DIR)/ppe_rx.bin
	$(INSTALL) -D -m 0755 $(LLCE_FIRMWARE_DIR)/ppe_tx.bin $(LLCE_FIRMWARE_INSTALL_IMAGE_DIR)/ppe_tx.bin
endef

$(eval $(generic-package))
